package org.bill.controller;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * hello world测试类
 * 
 * @author 米mi
 *
 */
@RequestMapping(value = "/hello")
@Controller
public class HelloController {

    /**
     * 测试
     * 
     * @return 视图+参数（hello world）
     */
    @RequestMapping(value = "/say", method = RequestMethod.GET)
    public ModelAndView sayHello() {
        ModelAndView model = new ModelAndView();
        model.setViewName("hello");
        model.addObject("message", "hello world");
        return model;
    }

    @RequestMapping(value = "/agent")
    public void getUserAgent(HttpServletRequest request) {
        String header = request.getHeader("User-Agent");
        System.out.println(header);

        String url = request.getLocalAddr() + ":" + request.getLocalPort() + "/" + request.getLocalName();
        System.out.println(url);

        Locale local = request.getLocale();
        System.out.println(local.getCountry() + " - " + local.getLanguage() + " - " + local.getDisplayCountry());

        String pathInfo = request.getPathInfo();
        System.out.println(pathInfo);

        String name = System.getProperty("os.name");
        System.out.println(name);

        String arch = System.getProperty("os.arch");
        System.out.println(arch);
    }

}
